﻿@page "/admin/vmanage/animation"
@layout ImoviesBlazorAntPro.BasicLayout
@attribute [Authorize]
@*@attribute [Authorize(Roles = "admin")]*@
@*@attribute [Authorize(Roles = "guest")]*@

<PageContainer Title="动漫管理">
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem>Admin</BreadcrumbItem>
            <BreadcrumbItem>视频管理</BreadcrumbItem>
            <BreadcrumbItem>动漫</BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <ChildContent>
        <Card>
            <Table PaginationPosition="bottomLeft" TItem="AnimationDto" DataSource="@dataList" Total="_total" @bind-PageIndex="_pageIndex" @bind-PageSize="_pageSize" @bind-SelectedRows="selectedRows" Size="TableSize.Small">
                <TitleTemplate>
                    <Button Type="@ButtonType.Primary" Icon="@IconType.Outline.Plus" OnClick="ShowAddModal">添加</Button>
                     <Button Danger Type="@ButtonType.Primary" Icon="@IconType.Outline.Delete" OnClick="BatchDelete">批量删除</Button>
                </TitleTemplate>

                 <ChildContent>
                     <Selection Key="@(context.Id)" />
                     <PropertyColumn Title="Id" Ellipsis Property="x=>x.Id" Sortable />
                     <PropertyColumn Title="名称" Property="x=>x.Name" Sortable />
                     <PropertyColumn Title="年份" Property="x=>x.Year" Sortable />
                     <PropertyColumn Title="类型" Property="x=>x.Category" />
                     <PropertyColumn Title="地区" Property="x=>x.Region" />
                     <PropertyColumn Title="链接" Ellipsis Property="x=>x.Url" />
                     <PropertyColumn Title="简介" Ellipsis Property="x=>x.Intro" />
                     <PropertyColumn Title="评价" Ellipsis Property="x=>x.Comment" />
                     <ActionColumn Title="操作" Align="@ColumnAlign.Center" Width="160">
                         <Space>
                             <SpaceItem>
                                 <Button Type="primary" Size="small" OnClick="()=>ShowEditModal(context)" Style="margin-right: 10px;">编辑</Button>
                             </SpaceItem>
                             <SpaceItem>
                                 <Popconfirm Title="确定删除吗?" OkText="确认" CancelText="取消"
                                             OnConfirm="()=>ConfirmDeleteAsync(context.Id)">
                                 <Button Danger Size="small">删除</Button>
                                 </Popconfirm>
                             </SpaceItem>
                         </Space>
                     </ActionColumn>
                 </ChildContent>
             </Table>

         </Card>
     </ChildContent>
 </PageContainer>


 <Modal Title="添加" Width="800" MaxBodyHeight="@("620px")" MaskClosable="@false"
        Visible="@_addModalVisible" OkText="@("提交")" CancelText="@("取消")"
        Centered="true"
        OnOk="@HandleAddModalOkAsync"
        OnCancel="@HandleAddModalCancel">
     <Form Model="@addModel"
           LabelColSpan="4"
           WrapperColSpan="20"
           OnFinish="OnAddFormFinish"
           OnFinishFailed="OnAddFormFinishFailed"
     @ref="@_addForm">
         <FormItem Label="名称">
             <Input @bind-Value="@context.Name" />
         </FormItem>
         <FormItem Label="url">
             <Input @bind-Value="@context.Url" />
         </FormItem>
         <FormItem Label="类型">
             <Input @bind-Value="@context.Category" />
         </FormItem>
         <FormItem Label="地区">
             <Input @bind-Value="@context.Region" />
         </FormItem>
         <FormItem Label="年份">
             <AntDesign.InputNumber Style="width: 100%;" @bind-Value="@context.Year" />
         </FormItem>
         <FormItem Label="导演">
             <Input @bind-Value="@context.Director" />
         </FormItem>
         <FormItem Label="主演">
             <Input @bind-Value="@context.Actors" />
         </FormItem>
         <FormItem Label="图片">
             <Input @bind-Value="@context.Img" />
         </FormItem>
         <FormItem Label="简介">
             <Input @bind-Value="@context.Intro" />
         </FormItem>
         <FormItem Label="评价">
             <Input @bind-Value="@context.Comment" />
         </FormItem>
     </Form>
 </Modal>


 <Modal Title="编辑" Width="800" MaxBodyHeight="@("620px")" MaskClosable="@false"
        Visible="@_editModalvisible" OkText="@("提交")" CancelText="@("取消")"
        Centered="true"
        OnOk="@HandleEditModalOkAsync"
        OnCancel="@HandleEditModalCancel">
     <Form Model="@editModel"
           LabelColSpan="4"
           WrapperColSpan="20"
           OnFinish="OnEditFormFinish"
           OnFinishFailed="OnEditFormFinishFailed"
     @ref="@_editForm">
         <FormItem Label="名称">
             <Input @bind-Value="@context.Name" />
         </FormItem>
         <FormItem Label="url">
             <Input @bind-Value="@context.Url" />
         </FormItem>
         <FormItem Label="类型">
             <Input @bind-Value="@context.Category" />
         </FormItem>
         <FormItem Label="地区">
             <Input @bind-Value="@context.Region" />
         </FormItem>
         <FormItem Label="年份">
             <AntDesign.InputNumber Style="width: 100%;" @bind-Value="@context.Year" />
         </FormItem>
         <FormItem Label="导演">
             <Input @bind-Value="@context.Director" />
         </FormItem>
         <FormItem Label="主演">
             <Input @bind-Value="@context.Actors" />
         </FormItem>
         <FormItem Label="图片">
             <Input @bind-Value="@context.Img" />
         </FormItem>
         <FormItem Label="简介">
             <Input @bind-Value="@context.Intro" />
         </FormItem>
         <FormItem Label="评价">
             <Input @bind-Value="@context.Comment" />
         </FormItem>
     </Form>
 </Modal>
